<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>课后作业</title>
  <!-- 公共资源 -->
  <script src="./js/jquery.min.js"></script>
  <script src="./js/rem.js"></script>
  <link rel="stylesheet" href="./css/common.css">
  <!-- 公共资源结束 -->
  <link rel="stylesheet" href="./css/afterClassTask.css">
</head>

<body>
  <div id="app">
    <div class="afterClassTask">
      <div class="navTitle">第一课：把钱放在正确的 位置</div>
      <form action="" id="formData">
        <div class="row">
          <div class="name">1·为什么大部分人会故事割韭菜？</div>
          <div class="col">
            <input type="radio" name="radio" value="1" id="radio1" />
            <label for="radio1">A<span>运气不好</span></label>
          </div>
          <div class="col">
            <input type="radio" name="radio" value="2" id="radio2" />
            <label for="radio2">B<span>智商比较低</span></label>
          </div>
          <div class="col">
            <input type="radio" name="radio" value="3" id="radio3" />
            <label for="radio3">C<span>没有系统的学习方法</span></label>
          </div>
        </div>
        <div class="row">
          <div class="name">2如果1月1日你刚好有1万元资产，但没有做任何投资，而今年的通货膨胀率是6%，那么1年后，这笔钱的实际购买力相当于多少钱?</div>
          <div class="col">
            <input type="radio" name="money" value="1" id="money1" />
            <label for="money1">A<span>运气不好</span></label>
          </div>
          <div class="col">
            <input type="radio" name="money" value="2" id="money2" />
            <label for="money2">B<span>智商比较低</span></label>
          </div>
          <div class="col">
            <input type="radio" name="money" value="3" id="money3" />
            <label for="money3">C<span>没有系统的学习方法</span></label>
          </div>
        </div>
        <div class="button">提交作业</div>
      </form>
    </div>
  </div>
</body>
<script type="text/javascript">
  $('.col').click(function () {
    $(this).find('input').prop("checked",true)
    var formData = $('#formData').serializeArray();
    if(formData.length === $('.row').length){
      $('.button').addClass('submit')
    }else{
      $('.button').removeClass('submit')
    }
  })
  $('label').click(function (e) {
    e.preventDefault();
  });
  //提交值
  $("#app").on("click",".submit",function(event){
    var formData = $('#formData').serializeArray();
    alert(JSON.stringify(formData))
    console.log(formData)
  })
</script>

</html>